package com.person.title.action;

import java.util.List;

import com.person.commons.struts2.BaseAction;
import com.person.link.service.LinkService;
import com.person.title.model.Title;
import com.person.title.model.TitleFunc;
import com.person.title.model.TitleSub;
import com.person.title.service.SubFuncService;
import com.person.title.service.TitleService;
import com.person.title.service.TitleSubService;

/**
 * 栏目功能
 * 
 * @author sam
 *
 */
public class SubFuncAction extends BaseAction {

	private Title title ;
	private TitleSub titleSub ;
	private String parentCode ;
	private SubFuncService subFuncService ;
	private TitleService titleService ;
	private TitleSubService titleSubService ; 
	private List <Title> titles ;
	private int flag = 0 ;
	//从栏目功能表获得具体功能
	private LinkService linkService;
	private TitleFunc titleFunc;
	
	
	
	
	public String index () {				
		return "index" ;
	}
	
	public String top () {
		return "top" ;		
	}
	
	public String right () {
		return "right" ;
	}
	
	
	/**
	 * 栏目管理-栏目功能的首页左边的栏目树形显示
	 * @return
	 */
	public String subFuncLeft () {	
		titles = this.titleService.titleList() ;
		return "subFuncLeft" ;
	}
	
	/**
	 * 栏目功能管理
	 * @return
	 */
	public String managerSubFunc(){
		
		titleSub = this.titleSubService.findTitleSubById(titleSub.getSubId()) ;
		//从栏目功能表获得具体功能
		titleFunc = linkService.findTitleFuncByFuncId(titleSub.getFuncId());
		return "managerSubFunc";
	}
	
	public String createSubFunc () {
		
		this.subFuncService.updateTitleSubFunc(titleSub.getSubId(), titleSub.getFuncId()) ;
		
		info = getText("subFunc.manage.success");	
		return "success" ;
	}
	
	
	
	/**
	 * 栏目组织结构树型显示
	 * XLoadtree的后台调用的方法
	 * @return
	 */
	public String subFuncTree () {
		info = this.subFuncService.subFuncTree(parentCode, request) ;
		return "tree" ;		
	}
	
	
	public String preCreateSubFunc () {
		return "createSubFunc" ;		
	}

	public Title getTitle() {
		return title;
	}

	public void setTitle(Title title) {
		this.title = title;
	}

	public TitleSub getTitleSub() {
		return titleSub;
	}

	public void setTitleSub(TitleSub titleSub) {
		this.titleSub = titleSub;
	}

	public String getParentCode() {
		return parentCode;
	}

	public void setParentCode(String parentCode) {
		this.parentCode = parentCode;
	}

	public SubFuncService getSubFuncService() {
		return subFuncService;
	}

	public void setSubFuncService(SubFuncService subFuncService) {
		this.subFuncService = subFuncService;
	}

	public int getFlag() {
		return flag;
	}

	public void setFlag(int flag) {
		this.flag = flag;
	}

	public TitleSubService getTitleSubService() {
		return titleSubService;
	}

	public void setTitleSubService(TitleSubService titleSubService) {
		this.titleSubService = titleSubService;
	}

	public List<Title> getTitles() {
		return titles;
	}

	public void setTitles(List<Title> titles) {
		this.titles = titles;
	}

	public TitleService getTitleService() {
		return titleService;
	}

	public void setTitleService(TitleService titleService) {
		this.titleService = titleService;
	}

	/**
	 * @param linkService the linkService to set
	 */
	public void setLinkService(LinkService linkService) {
		this.linkService = linkService;
	}

	/**
	 * @return the titleFunc
	 */
	public TitleFunc getTitleFunc() {
		return titleFunc;
	}

	/**
	 * @param titleFunc the titleFunc to set
	 */
	public void setTitleFunc(TitleFunc titleFunc) {
		this.titleFunc = titleFunc;
	}

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
